﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint;
using System.Web.Security;

namespace JM.JCY.SharePointComponent.UserManagement.GetMembershipUser_test
{
    public partial class GetMembershipUser_testUserControl : UserControl
    {
        private static SPIisSettings _SPIisSettings;
        internal static SPIisSettings SPIisSettings
        {
            get
            {
                if (_SPIisSettings == null)
                {
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        _SPIisSettings = SPContext.Current.Site.WebApplication.GetIisSettingsWithFallback(SPContext.Current.Site.Zone);
                    });
                }

                return _SPIisSettings;
            }
        }

        internal static MembershipProvider MembershipProvider
        {
            get
            {
                return Membership.Providers[SPIisSettings.FormsClaimsAuthenticationProvider.MembershipProvider];
            }
        }

        internal static RoleProvider RoleProvider
        {
            get
            {
                return Roles.Providers[SPIisSettings.FormsClaimsAuthenticationProvider.RoleProvider];
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            string currentAccount = SPContext.Current.Web.CurrentUser.Name;
            MembershipUser membershipUser = MembershipProvider.GetUser(currentAccount, false);
        }
    }
}
